package com.woniuxy.yygh.common.utils;

import com.woniuxy.yygh.common.helper.JwtHelper;

import javax.servlet.http.HttpServletRequest;

/**
 * <P> @Author: ideaAdmin
 * <P> TODO: Class
 * <P> TODO: 获取当前用户的工具类
 * <P> Date: 2022/3/4:21:07
 * <P> Description:
 */

public class AuthContextHolder {

    /**
     * TODO:获取当前用户id
     **/
    public static Long getUserId(HttpServletRequest request) {
        //获得token jwt里获得userid
        String token = request.getHeader("token");
        Long userId = JwtHelper.getUserId(token);
        return  userId;
    }

    /**
     * TODO:获取当前用户名称
     **/
    public static String getUserName(HttpServletRequest request) {
        //获得token jwt里获得userid
        String token = request.getHeader("token");
        return  JwtHelper.getUserName(token);
    }
}
